<?php $this->load->view('admin/public/head.html', array('css' => array(
    '/assets/admin/css/admin/common.css'
))); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper catsAdmin" ng-controller="admin-goods-category-controller">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            商城管理
            <small>商城基础描述信息</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 商城管理</a></li>
            <li class="active">基础设置</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <!-- Your Page Content Here -->
        <div class="row">
            <div class="col-md-7">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">分类设置</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body no-padding">
                        <table class="table cat-setting">
                            <tr>
                                <th style="width: 50px">#</th>
                                <th style="width: 30px"></th>
                                <th>分类名称</th>
                                <th class="text-center" style="width: 76px;">排序</th>
                                <th style="width: 75px" class="text-center">操作</th>
                            </tr>
                            <tbody>
                            <tr class="p-tr">
                                <td class="cat-parent">
                                    <div class="parent-list-icon"></div>
                                </td>
                                <td colspan="2">
                                    <input type="text" ng-model="addParentCatName" ng-blur="addPCat()" class="form-control ipt-cat-p"  placeholder="添加父级分类">
                                </td>
                                <td>
                                </td>
                                <td class="text-left">
                                </td>
                            </tr>
                            </tbody>
                            <tbody ng-repeat="(index, c) in categories | orderBy:c.sort:false">
                            <tr class="p-tr">
                                <td class="cat-parent">
                                    <div class="parent-list-icon"></div>
                                </td>
                                <td colspan="2">
                                    <input type="text" ng-model="c.name" ng-blur="resetCat('p', c.id, c.name, index)" class="form-control ipt-cat-p"  placeholder="添加父级分类">
                                </td>
                                <td>
                                    <input type="text" class="form-control ipt-cat-sort" ng-blur="resetPSort(index, c.id, c.sort)" ng-model="c.sort" placeholder="排序">
                                </td>
                                <td class="text-left">
                                    <button class="btn btn-link" ng-if="c.subCats.length == 0" ng-click="remove('p', index, c.id)">删除</button>
                                    <button class="btn btn-link" ng-click="setSubBtn(c.id)">添加</button>
                                </td>
                            </tr>
                            <tr class="s-tr" ng-show="addSub_{{ c.id }}">
                                <td colspan="2" class="cat-parent">
                                    <div class="son-list-icon"></div>
                                </td>
                                <td>
                                    <input type="text" class="form-control ipt-cat-p" ng-model="subNewName" ng-blur="addSubCat(c.id, subNewName, index)" placeholder="添加子分类">
                                </td>
                                <td>
                                </td>
                                <td class="text-left">
                                    <button class="btn btn-link" ng-click="cancelSubBtn(c.id)">取消</button>
                                </td>
                            </tr>
                            <tr class="s-tr" ng-repeat="(key, s) in c.subCats | orderBy:s.sort:false">
                                <td colspan="2" class="cat-parent">
                                    <div class="son-list-icon"></div>
                                </td>
                                <td>
                                    <input type="text" class="form-control ipt-cat-p" ng-model="s.name" ng-blur="resetCat('s', s.id, s.name, index, key)" placeholder="添加子分类">
                                </td>
                                <td>
                                    <input type="text" class="form-control ipt-cat-sort" ng-blur="resetSonSort(index, key, s.id, s.sort)" ng-model="s.sort" placeholder="排序">
                                </td>
                                <td class="text-left">
                                    <button class="btn btn-link" ng-click="remove('s', index, s.id, key)">删除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">
                        &nbsp;
                    </div>
                </div>
            </div>
            <div class="col-md-5">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">计量单位设置</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <form class="form-horizontal">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="addUnit" class="col-sm-3 control-label">计量单位</label>

                                    <div class="col-sm-6">
                                        <input type="text" class="form-control" ng-model="addUnitName" id="addUnit" placeholder="填写计量单位">
                                    </div>
                                    <div class="col-sm-3"><a href="javascript:;" ng-click="addUnit()" class="btn btn-info" style="background: #00a65a; border: none;">添加</a></div>
                                </div>
                            </div>
                        </form>
                        <table class="table table-bordered">
                            <tr>
                                <th style="width: 30px" class="text-center">#</th>
                                <th class="text-center">分类名称</th>
                                <th style="width: 60px" class="text-center">操作</th>
                            </tr>
                            <tr ng-repeat="(key, u) in units">
                                <td class="text-center" ng-bind="u.id"></td>
                                <td class="text-center" ng-bind="u.name"></td>
                                <td class="text-center"><a href="javascript:;" ng-click="removeUnit(key, u.id)" class="btn btn-link btn-xs"><i class="fa fa-close"></i> 删除</a></td>
                            </tr>
                            <tr ng-if="units.length == 0">
                                <td colspan="3"><p class="text-center help-block">暂无数据</p></td>
                            </tr>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">&nbsp;</div>
                </div>
                <!-- /.box -->
            </div>
        </div>
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php $this->load->view('admin/public/foot.html', array('js' => array(
    '/assets/admin/js/goods/category.js'
))); ?>
